﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
{% load static %}
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>任务管理</title>
    <link href="{% static 'assets/css/bootstrap.css' %}" rel="stylesheet"/>
    <link href="{% static 'assets/css/font-awesome.css' %}" rel="stylesheet"/>
    <link href="{% static 'assets/js/morris/morris-0.4.3.min.css' %}" rel="stylesheet"/>
    <link href="{% static 'assets/css/custom-styles.css' %}" rel="stylesheet"/>
    <link href="{% static 'assets/datetimepicker/bootstrap-datetimepicker.min.css' %}" rel="stylesheet"/>
    <link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'/>

</head>

<body>
<div id="wrapper">
    <!-- 头部bar -->
    <nav class="navbar navbar-default top-navbar" role="navigation">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/admin/index">POM - 自动化测试平台
            </a>
        </div>

        <ul class="nav navbar-top-links navbar-right color-white">
            <li>
                <a href="/login/" class=" pointer">退出登录</a>
            </li>
            <li><span class="mar-rignt-100">{{user}}</span></li>
        </ul>
    </nav>
    <!-- 头部bar end -->
    <!-- 左侧导航  -->
    <nav class="navbar-default navbar-side" role="navigation">
        <div class="sidebar-collapse">
            <ul class="nav" id="main-menu">

                <li>
                    <a href="/admin/index"><i class="fa fa-dashboard"></i> 系统概括</a>
                </li>
                <li>
                    <a href="/admin/project"><i class="fa fa-desktop"></i> 项目管理</a>
                </li>
                <li>
                    <a href="/admin/page"><i class="fa fa-bar-chart-o"></i> 页面管理</a>
                </li>
                <li>
                    <a href="/admin/element"><i class="fa fa-qrcode"></i> 页面元素</a>
                </li>

                <li>
                    <a href="/admin/keyword"><i class="fa fa-table"></i> 关键字库</a>
                </li>
                <li>
                    <a href="/admin/testcase"><i class="fa fa-edit"></i> 测试用例 </a>
                </li>
                <li>
                    <a href="/admin/result"><i class="fa fa-fw fa-file"></i> 测试结果 </a>
                </li>
                <li>
                    <a href="/admin/loginConfig"><i class="fa fa-fw fa-building-o"></i> 登录配置 </a>
                </li>
                <li>
                    <a class="active-menu" href="/admin/task"><i class="fa fa-fw fa-sitemap"></i> 任务管理 </a>
                </li>
            </ul>
        </div>

    </nav>
    <!-- 左侧导航  -->
    <div id="page-wrapper">
        <div id="page-inner">
            <div class="row">
                <div class="col-md-12">
                    <h1 class="page-header">
                        任务管理
                    </h1>
                </div>
            </div>
            <!-- /. ROW  -->
            <!-- /. 表格  -->
            <div class="row">
                <div class="col-md-12">
                    <!-- Advanced Tables -->
                    <div class="panel panel-default">
                        <!--<div class="panel-heading">表格名字</div>-->
                        <div class="panel-body" style="min-height:600px">
                            <div class="row mar-bottom-20">
                                <div class="col-lg-12">
                                    <div class="form-inline">
                                        <div class="form-group">
                                            <input type="text" class="form-control" placeholder="任务名称" id="name">
                                        </div>
                                        <div class="form-group">
                                            <!--<label class="sr-only" for="name">名称</label>-->
                                            <select class="form-control" id="newtiming">
                                                <option>任务类型</option>
                                                <option id="1" value="定时">定时</option>
                                                <option id="2" value="常规">常规</option>
                                            </select>
                                        </div>

                                        <div class="form-group">
                                            <label class="control-label width-80 text-right">创建时间：</label>
                                            <div class="form-control-custom">
                                                <div class="input-group date form_datetime width-200" id="pzTime"
                                                     data-date="2018-01-01" data-date-format="yyyy-mm-dd"
                                                     data-link-field="dtp_input_start">
                                                    <input class="form-control" size="16" type="text" value=""
                                                           placeholder="开始时间" readonly>
                                                    <span class="input-group-addon"><span
                                                            class="glyphicon glyphicon-th"></span></span>
                                                </div>
                                                <input type="hidden" id="dtp_input_start" value=""/>
                                            </div>

                                            <div class="form-control-custom">
                                                <div class="input-group date form_datetime width-200" id="pzqxTime"
                                                     data-date="2018-01-01" data-date-format="yyyy-mm-dd"
                                                     data-link-field="dtp_input_end">
                                                    <input class="form-control" size="16" type="text" value=""
                                                           placeholder="结束时间" readonly>
                                                    <span class="input-group-addon"><span
                                                            class="glyphicon glyphicon-th"></span></span>
                                                </div>
                                                <input type="hidden" id="dtp_input_end" value=""/>

                                            </div>

                                        </div>

                                        <button type="submit" class="btn btn-primary" onclick="search()">搜索</button>
                                        <button type="button" class="btn btn-info" onclick="createTask()">新建
                                        </button>
                                    </div>

                                </div>
                            </div>
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                    <thead>
                                    <tr>
                                        <th width="70px">序号</th>
                                        <th width="100px">任务名称</th>
                                        <th width="100px">任务类型</th>
                                        <th width="120px">备注信息</th>
                                        <th width="100px">创建时间</th>
                                        <th width="100px">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody class="js_table">
                                    </tbody>
                                </table>
                            </div>

                        </div>
                    </div>
                    <!--End Advanced Tables -->
                </div>
            </div>

            <!-- /. 表格  -->
            <footer>
                <p class="text-center"></p>
            </footer>
        </div>
        <!-- /. PAGE INNER  -->
    </div>
    <!-- /. PAGE WRAPPER  -->
</div>
<!-- /. WRAPPER  -->

<div class="modal fade" id="guanlian" tabindex="-1" role="dialog" aria-labelledby="myModalLabe0" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabe0">新建任务</h4>
            </div>
            <div class="modal-body">
                <!--内容-->
                <div class="form-horizontal">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">任务名称</label>
                        <div class="col-sm-10">
                            <input id='taskName' type="text" class="form-control">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="lastname" class="col-sm-2 control-label">任务类型</label>
                        <div class="col-sm-10">
                            <div class="radio" style="display:inline-block; margin-right:20px">
                                <label>
                                    <input type="radio" name="taskType" value="1" checked="">定时任务
                                </label>
                            </div>
                            <div class="radio" style="display:inline-block">
                                <label>
                                    <input type="radio" name="taskType" value="2">常规任务
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="lastname" class="col-sm-2 control-label">浏览器</label>
                        <div class="col-sm-10">
                            <select id='browsers' multiple="" class="form-control">
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">备注信息</label>
                        <div class="col-sm-10">
                            <textarea id="remark" class="form-control" rows="4"></textarea>
                        </div>
                    </div>
                </div>
                <div class="form-group f-c">
                    <div class="col-sm-12 mar-top-6">
                        <a data-toggle="modal" class="pointer" onclick="newTestCase()">添加用例</a>
                        <div class="table-responsive">
                            <table class="table table-striped table-bordered table-hover" id="result-table">
                                <thead>
                                <tr>
                                    <th>项目</th>
                                    <th>测试用例</th>
                                    <th>测试环境</th>
                                    <th>操作</th>

                                </tr>
                                </thead>
                                <tbody id="testcases">
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-10">
                        <div id='message' class="col-sm-10 js_message text-danger"></div>
                    </div>
                </div>
                <!--内容-->

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">
                    取消
                </button>
                <button type="button" class="btn btn-primary" id="saveTask">
                    保存
                </button>
            </div>
        </div>
    </div>
</div>
<!--end 新建任务-->

<!--添加用例-->
<div class="modal fade" id="newProject" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" onclick="closeNewTestCase()">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    添加用例</h4>
            </div>
            <div class="modal-body">
                <!--内容-->
                <form class="form-horizontal" role="form">
                    <div class="form-group">
                        <label for="firstname" class="col-sm-2 control-label">选择项目</label>
                        <div class="col-sm-10">
                            <select id="projectSelect" class="form-control">
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="lastname" class="col-sm-2 control-label">测试用例</label>
                        <div class="col-sm-10">
                            <select id="testcaseSelect" class="form-control">
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="lastname" class="col-sm-2 control-label">测试环境</label>
                        <div class="col-sm-10">
                            <select id="es" multiple="" class="form-control">
                            </select>
                            <br> 按住键盘ctrl + 点击鼠标左键可多选
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"></label>
                        <div id='addTestCaseMessage' class="col-sm-10 js_message text-danger"></div>
                    </div>
                </form>
                <!--内容-->

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" onclick="closeNewTestCase()">
                    取消
                </button>
                <button type="button" class="btn btn-primary" onclick="addTestcase()">
                    确定
                </button>

            </div>
        </div>
    </div>
</div>
<!--end 添加用例-->

<!--end 运行弹窗-->

<!--提交成功 可选择是否用这个弹窗-->
<div class="modal fade" id="tjcg" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    提交成功</h4>
            </div>
            <div class="modal-body">
                <!--内容-->
                用例执行申请已提交，但可能还在排队或执行中，是否立即查看结果？

                <!--内容-->

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">
                    否
                </button>
                <button type="button" class="btn btn-primary" onclick="toResult()">
                    是
                </button>

            </div>
        </div>
    </div>
</div>
<!--end 提交成功-->
<!--删除询问弹窗提示-->
<div class="modal fade" id="DelXProject1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title">删除测试任务</h4>
            </div>
            <div class="modal-body">
                <p>请确认是否删除测试任务</p>
                <p class="js_DELmessage text-danger"></p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="del">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

<script src="{% static 'assets/js/jquery-1.10.2.js' %}"></script>
<script src="{% static 'assets/js/bootstrap.min.js' %}"></script>
<script src="{% static 'assets/js/jquery.metisMenu.js' %}"></script>
<script src="{% static 'assets/js/morris/raphael-2.1.0.min.js' %}"></script>
<script src="{% static 'assets/js/morris/morris.js' %}"></script>
<script src="{% static 'assets/js/dataTables/jquery.dataTables.js' %}"></script>
<script src="{% static 'assets/js/dataTables/dataTables.bootstrap.js' %}"></script>
<script src="{% static 'assets/js/custom-scripts.js' %}"></script>
<script src="{% static 'assets/datetimepicker/bootstrap-datetimepicker.min.js' %}"></script>
<script src="{% static 'assets/datetimepicker/bootstrap-datetimepicker.zh-CN.js' %}"></script>
<script src="{% static 'assets/datetimepicker/moment-with-locales(1).js' %}"></script>

<script>

    search();

    function closeNewTestCase() {
        $("#newProject").modal("hide");
        $("#guanlian").modal("show");
        $("#message").html("");
    }

    $("#projectSelect").on('change', function () {
        $("#testcaseSelect").find("option").remove();
        $("#es").find("option").remove();
        var projectId = $("#projectSelect option:selected").val();//所属项目
        $.ajax({
            url: '/api/v1/testcase?p=1',
            type: 'post',
            dataType: 'json',
            data: JSON.stringify({"projectId": projectId, "pageSize": 9999999}),
            success: function (res) {
                if (res.code == 200) {
                    for (var i = 0; i < res.data.testcase.length; i++) {
                        $("#testcaseSelect").append('<option value="' + res.data.testcase[i].id + '">' + res.data.testcase[i].title + '</option>');
                    }
                }
            }
        });
        $.ajax({
            url: '/api/v1/environment?p=1',
            type: 'post',
            dataType: 'json',
            data: JSON.stringify({"projectId": projectId, "pageSize": 9999999}),
            success: function (res) {
                if (res.code == 200) {
                    for (var i = 0; i < res.data.environments.length; i++) {
                        if (projectId == res.data.environments[i].projectId) {
                            $("#es").append('<option value="' + res.data.environments[i].id + '">' + res.data.environments[i].name + '</option>');
                        }
                    }
                }
            }
        });
    });

    function newTestCase() {
        $("#guanlian").modal("hide");
        $("#projectSelect").val("999999999");
        $("#addTestCaseMessage").html("")
        $("#testcaseSelect").find("option").remove();
        $("#es").find("option").remove();
        $("#newProject").modal("show");
    }

    function addTestcase() {
        var projectId, projectName;
        var testcaseId, testcaseTitle;
        var esid, es;
        esid = $("#es option:selected").map(function () {
            return $(this).val();
        }).get()
        projectId = $("#projectSelect option:selected").val();
        projectName = $("#projectSelect option:selected").text();
        testcaseId = $("#testcaseSelect option:selected").val();
        testcaseTitle = $("#testcaseSelect option:selected").text();
        var data = {"id": testcaseId, "environments": esid};
        es = $("#es option:selected").map(function () {
            return $(this).text();
        }).get()
        if (esid.length == 0 || typeof(testcaseId) == "undefined") {
            $("#addTestCaseMessage").html("请选择测试用例与测试环境")
        } else {
            var tr = '';
            tr += "<tr class='odd'>";
            tr += "<td class='center'>" + projectName + "</td>";
            tr += '<td class="center">' + testcaseTitle + '</td>';
            tr += '<td class="center">';
            for (var e in es) {
                tr += (es[e] + "</br>");
            }
            tr += '</td>';
            tr += '<td class="center">';
            tr += '<a class="pointer" onclick="delTestCase(this)">删除</a>';
            tr += '</td>';
            tr += '<td class="data" style="display:none">' + JSON.stringify(data) + '</td>';
            tr += '</tr>';
            $("#testcases").append(tr);
            $("#newProject").modal("hide");
            $("#guanlian").modal("show");
        }
    }

    $.ajax({
        url: '/api/v1/browser',
        type: 'POST',
        dataType: 'json',
        success: function (res) {
            if (res.code == 200) {
                var options = ""
                for (var i = 0; i < res.data.browsers.length; i++) {
                    options += '<option value="' + res.data.browsers[i].id + '">' + res.data.browsers[i].name + '</option>';
                }
                $("#browsers").append(options)
            }
        }
    });

    function createTask() {
        $("#message").html("");
        $('#testcases').find("tr").remove();
        $("#taskName").val("");
        $("input:radio[value='1']").prop('checked', true);
        $('#remark').val("");
        $('#browsers').val("1");
        $("#myModalLabe0").html("新建任务");
        $("#guanlian").modal("show");
        $("#saveTask").attr("onclick", "create()")

    }

    function create() {
        var taskName, taskType, browsers, testCases, remark;
        taskName = $("#taskName").val();
        taskType = $('.radio input[name="taskType"]:checked ').val();
        remark = $('#remark').val();
        browsers = $('#browsers').val();
        var tlist = [];
        var tcElements = $("#testcases").find("tr").find("td.data");
        tcElements.each(function (i, v) {
            tlist.push(JSON.parse($(v).text()));
        });
        testCases = tlist;
        $.ajax({
            url: '/api/v1/task/create',
            type: 'post',
            //data:formParam,
            data: JSON.stringify({
                "name": taskName,
                "timing": taskType,
                "testcases": testCases,
                "browsers": browsers,
                "remark": remark,
            }),
            dataType: 'json',
            success: function (res) {
                if (res.code == 200) {
                    $("#guanlian").modal("hide");
                    setTimeout(function () {
                        search();
                    }, 1000)
                    $('#DelXProject1').modal('hide');
                } else {
                    $("#message").html(res.message);
                }
            }
        });
    }

    function edit(id) {
        $("#message").html("");
        $("#testcases").find("tr").remove()
        $("input:radio").removeAttr("checked");
        $("#myModalLabe0").html("编辑任务");
        $.ajax({
            url: '/api/v1/task/' + id,
            type: 'POST',
            dataType: 'json',
            success: function (res) {
                if (res.code == 200) {
                    $("#taskName").val(res.data.name);
                    $("input:radio[value='" + res.data.timing + "']").prop('checked', true);
                    $("#remark").val(res.data.remark);
                    $("#browsers").val(res.data.browsers);
                    var tr = '';
                    for (var i = 0; i < res.data.testcases.length; i++) {
                        tr += "<tr class='odd'>";
                        tr += "<td class='center'>" + res.data.testcases[i].projectName + "</td>";
                        tr += '<td class="center">' + res.data.testcases[i].testcaseTitle + '</td>';
                        tr += '<td class="center">';
                        for (var e in res.data.testcases[i].environments) {
                            tr += (res.data.testcases[i].environments[e] + "</br>");
                        }
                        tr += '</td>';
                        tr += '<td class="center">';
                        tr += '<a class="pointer" onclick="delTestCase(this)">删除</a>';
                        tr += '</td>';
                        tr += '<td class="data" style="display:none">' + JSON.stringify(res.data.testcases[i].data) + '</td>';
                        tr += '</tr>';
                    }
                    $("#testcases").append(tr);
                } else {
                    $("#message").html(res.message)
                }
            }
        });
        $("#saveTask").attr("onclick", "editTask('" + id + "')");
        $("#guanlian").modal("show");
    }

    function delTestCase(_this) {
        $(_this).parent().parent().remove();
    }

    function editTask(id) {
        var taskName, taskType, browsers, testCases, remark;
        taskName = $("#taskName").val();
        taskType = $('.radio input[name="taskType"]:checked ').val();
        remark = $('#remark').val();
        browsers = $('#browsers').val();
        var tlist = [];
        var tcElements = $("#testcases").find("tr").find("td.data");
        tcElements.each(function (i, v) {
            debugger
            tlist.push(JSON.parse($(v).text()));
        });
        testCases = tlist;
        $.ajax({
            url: '/api/v1/task/edit/' + id,
            type: 'post',
            //data:formParam,
            data: JSON.stringify({
                "name": taskName,
                "timing": taskType,
                "testcases": testCases,
                "browsers": browsers,
                "remark": remark,
            }),
            dataType: 'json',
            success: function (res) {
                if (res.code == 200) {
                    $("#guanlian").modal("hide");
                    setTimeout(function () {
                        search();
                    }, 1000)
                    $('#DelXProject1').modal('hide');
                } else {
                    $("#message").html(res.message);
                }
            }
        });
    }

    /*搜索方法*/
    function search() {
        var nameTxt, name_xmT, name_xmS, creatTime1, creatTime2;
        nameTxt = $("#name").val();                              //用例标题
        name_xmT = $("#newtiming option:selected").attr('id');      //所属项目
        creatTime1 = $('#dtp_input_start').val()                 //开始时间
        creatTime2 = $('#dtp_input_end').val()                   //结束时间
        var datas = {
            "name": nameTxt,
            "timing": name_xmT,
            "startTime": creatTime1,
            "endTime": creatTime2,
            "pageSize": 99999
        }
        var data = JSON.stringify(datas);
        $.ajax({
            url: '/api/v1/task?p=1',
            type: 'post',
            dataType: 'json',
            data: data,
            success: function (res) {
                $('#dataTables-example').dataTable().fnClearTable();//清空数据.fnClearTable();//清空数据
                $('#dataTables-example').dataTable().fnDestroy(); //还原初始化了的datatable
                var tr = ''
                for (var i = 0; i < res.data.tasks.length; i++) {
                    var num_timing = res.data.tasks[i].timing;
                    tr += '<tr class="odd"><td class="center">' + (i + 1) + '</td>';
                    tr += '<td class="center">' + res.data.tasks[i].name + '</td>';
                    tr += '<td class="center">' + (num_timing == 1 ? "定时" : num_timing == 2 ? "常规" : "") + '</td>';
                    tr += '<td class="center">' + res.data.tasks[i].remark + '</td>';
                    tr += '<td class="center">' + res.data.tasks[i].createTime + '</td>';
                    tr += '<td class="center">';
                    tr += '<a href="javascript:void(0);" class="pointer"  onclick="run(' + res.data.tasks[i].id + ')">运行</a>';
                    tr += ' - ';
                    tr += '<a href="javascript:void(0);" class="pointer"  onclick="edit(' + res.data.tasks[i].id + ')">编辑</a>';
                    tr += ' - ';
                    tr += '<a href="javascript:void(0);" class="pointer"  onclick="isDel(' + res.data.tasks[i].id + ')">删除</a>';
                    tr += '</td></tr>';
                }
                $(".js_table").append(tr);
                $('#dataTables-example').dataTable({
                    "bPaginate": true,  //是否显示分页
                    "bSort": true,     //是否支持排序功能
                    "bAutoWidth": false, //自动宽度
                    "serverSide": false,
                    "pageLength": 10,
                    "sPaginationType": "full_numbers", //分页
                    "oLanguage": {      //多语言配置
                        "sLengthMenu": "每页显示 10 条记录",
                        "sZeroRecords": "对不起，查询不到任何相关数据",
                        "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",
                        "sInfoEmtpy": "找不到相关数据",
                        "sInfoFiltered": "数据表中共为 _MAX_ 条记录)",
                        "sProcessing": "正在加载中...",
                        "oPaginate": {
                            "sFirst": "第一页",
                            "sPrevious": " 上一页 ",
                            "sNext": " 下一页 ",
                            "sLast": " 最后一页 "
                        }
                    },
                });

            }
        });

        $("#projectSelect").find("option").remove();
        $("#projectSelect").append("<option value='999999999'>选择项目</option>"
        )
        $.ajax({
            url: '/api/v1/project?p=1',
            type: 'post',
            dataType: 'json',
            data: JSON.stringify({"pageSize": 999999}),
            success: function (res) {
                if (res.code == 200) {
                    for (var i = 0; i < res.data.projects.length; i++) {
                        $("#projectSelect").append("<option value='" + res.data.projects[i].id + "'>" + res.data.projects[i].name + "</option>")
                    }
                }
            }
        });

    }

    /*删除询问方法*/
    function isDel(id) {
        $('#DelXProject1').modal('show');
        $("#del").attr("onclick", "determine(" + id + ")");
        $(".js_DELmessage").html("");
    }

    /*删除方法*/
    function determine(id) {
        $.ajax({
            url: '/api/v1/task/delete/' + id,
            type: 'get',
            //data:formParam,
            dataType: 'json',
            success: function (res) {
                if (res.code == 200) {
                    setTimeout(function () {
                        //重新获取下列表
                        search();
                    }, 1000)
                    $('#DelXProject1').modal('hide');
                } else {
                    $(".js_DELmessage").html(res.message);
                }
            }
        });
    }

    function toResult() {
        $("#tjcg").modal("hide")
        window.open("/admin/result")
    }

    function run(id) {
        $.ajax({
            url: '/api/v1/task/running/' + id,
            type: 'post',
            dataType: 'json',
            success: function (res) {
                if (res.code == 200) {
                    $("#tjcg").modal("show")
                }
            }
        });
    }

    /*获取列表*/

    Date.prototype.Format = function (fmt) {
        var o = {
            "M+": this.getMonth() + 1, //月份
            "d+": this.getDate(), //日
            "h+": this.getHours(), //小时
            "m+": this.getMinutes(), //分
            "s+": this.getSeconds(), //秒
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
            "S": this.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    }
    //获得当前时间
    var newDate = new Date();
    var endTimeT1 = new Date(newDate.getFullYear(), newDate.getMonth(), newDate.getDate()).Format("yyyy-MM-dd");
    $("#pzTime,#pzqxTime").attr("data-date", endTimeT1)
    //开始时间
    $("#pzTime").datetimepicker({
        language: 'zh-CN',
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        minView: "month",
        format: 'yyyy-mm-dd',
        forceParse: 0,
        //endDate : new Date()
    }).on('hide', function (event) {
        event.preventDefault();
        event.stopPropagation();
        var startTime = event.date;
        $('#pzqxTime').datetimepicker('setStartDate', startTime);
        $('#pzqxTime').val("");
    });
    //结束时间
    $("#pzqxTime").datetimepicker({
        language: 'zh-CN',
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        minView: "month",
        format: 'yyyy-mm-dd',
        forceParse: 0,
        //endDate : new Date()
    }).on('hide', function (event) {
        event.preventDefault();
        event.stopPropagation();
        var endTime = event.date;
        var endTimeT = new Date(endTime.getFullYear(), endTime.getMonth(), endTime.getDate(), 23, 59, 59).Format("yyyy-MM-dd hh:mm:ss");
        $('#pzTime').datetimepicker('setEndDate', endTime);
        $("#dtp_input_end").attr("value", endTimeT);
    })
</script>

</body>

</html>